Carbon


PBHOpenAsync

Header: Files.h Carbon status: Supported

Opens the data fork of a file. Because PBHOpenAsync will also open devices, it’s safer to use the PBHOpenDFAsync function instead.

OSErr PBHOpenAsync (
    HParmBlkPtr paramBlock
);
paramBlock

A pointer to a basic HFS parameter block.

function result

A result code.

DISCUSSION

The relevant fields of the parameter block are:

The PBHOpenAsync function creates an access path to the data fork of the specified file and returns a file reference number in the ioRefNum field.

You can open a path for writing even if it accesses a file on a locked volume, and no error is returned until a PBWriteAsync, PBSetEOFAsync, or PBAllocateAsync call is made.

If you attempt to open a locked file for writing, PBHOpenAsync returns the result code permErr. If you request exclusive read/write permission but another access path is already open, PBHOpenAsync returns the reference number of the existing access path in ioRefNum and opWrErr as its function result. You should not use this reference number unless your application originally opened the file.

If you use PBHOpenAsync to try to open a file whose name begins with a period, you might mistakenly open a driver instead; subsequent attempts to write data might corrupt data on the target device. To avoid these problems, you should always use PBHOpenDFAsync instead of PBHOpenAsync.

AVAILABILITY

Supported in Carbon. Available in Mac OS 8.1 and later when Carbon 1.0.2 or later is present.


© 2000 Apple Computer, Inc. — (Last Updated 5/8/2000)